require "Common/define"
require "Logic/Config"
require "Common/functions"

RedDotsPrivateChatHandler = {};
local this = RedDotsPrivateChatHandler;

function RedDotsPrivateChatHandler.init()
    CloseEvent(Config.EventType.Fresh_Arena, this.update);
    ListenEvent(Config.EventType.Fresh_Arena, this.update);

    return this;
end


--参数 无
function RedDotsPrivateChatHandler.getFlag(...)
    local tab = logicMgr.ChatManager.returnSelfPrivateList()
    if not tab then
        --privateRedPoint.visible = false;
        return
    end
    if ... ~= nil then
        for k, v in pairs(tab) do
            if ... == v.PlayerId and v.unReadNum > 0 then
                return Config.RedDotsFlagState.Needful;
            end
        end
    else
        local num = 0
        for k, v in pairs(tab) do
            num = num + v.unReadNum
        end
        if num > 0 then
            --privateRedPoint.visible = true;
            --ChatManager.SetMsgNewById(Config.MsgChannel.Person, 1);
            return Config.RedDotsFlagState.Needful;

        else
            --privateRedPoint.visible = false;

            --ChatManager.SetMsgNewById(Config.MsgChannel.Person, nil);
            return Config.RedDotsFlagState.None;
        end
    end
    return Config.RedDotsFlagState.None;

end

function RedDotsPrivateChatHandler.update()
    RedDotsManager.addBroadcast(Config.RedDotsType.ArenaBattle);
end